package inc.prada.android.demo;

import java.util.Random;

import inc.prada.android.ext.controller.SportDisplayController;
import inc.prada.android.ext.view.ChartViewFactroy;
import inc.prada.android.ext.view.ISpectrum;
import inc.prada.android.ext.view.SpectrumView;
import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;

public class SpectrumViewSample extends Activity {
	private SportDisplayController controller;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        ISpectrum view = ChartViewFactroy.create("", this);
        view.init(10, 30);
        controller = new SportDisplayController(view);
        
        mUIReflashTask.execute();
        setContentView(view.getView());
    }
    
    AsyncTask<Void, Void, Void> mUIReflashTask = new AsyncTask<Void, Void, Void>() {
    	Random r = new Random();
		@Override
		protected Void doInBackground(Void... arg0) {
			while (true) {
				try {
					Thread.sleep(1000);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				System.out.println("random:"+r.nextInt(30));
				controller.add(r.nextInt(30));
				controller.update();
			}
		}
	};
}